<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.conn.RecordSet" %>
<%@page import="weaver.general.Util" %>
<jsp:useBean id="bb" class="weaver.general.BaseBean"/>
<%
    String xmvlaue = Util.null2String(request.getParameter("xmvlaue"));
    String bmvalue = Util.null2String(request.getParameter("bmvalue"));
    String lxvalue = Util.null2String(request.getParameter("lxvalue"));
    String lx = Util.null2String(request.getParameter("lx"));
    String workflowid = Util.null2String(request.getParameter("workflowid"));
    String xm = nameTransMethod(xmvlaue);
    String bm = bmTransMethod(bmvalue);
    String xlk = getSelectItem(lx,lxvalue,workflowid);
    String str = "{\"xm\":\"" + xm + "\",\"bm\":\"" + bm + "\",\"xlk\":\"" + xlk + "\"}";
    bb.writeLog(str);
    out.print(str);
%>
<%!
    //工号转换姓名方法
    public static String nameTransMethod(String param) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select workcode,lastname from hrmresource where id='" + param + "'");
        rs.next();
        String lastname = Util.null2String(rs.getString("lastname"));
        return lastname;
    }

    //部门转换方法
    public static String bmTransMethod(String param) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select id,departmentname from HrmDepartment where id='" + param + "'");
        rs.next();
        String departmentname = Util.null2String(rs.getString("departmentname"));
        return departmentname;
    }
    /**
     * 根据字段编码获取下拉框值
     *
     * @param fieldcode,fieldvalue
     * @return String
     */
    public static String getSelectItem(String fieldcode ,String fieldvalue,String workflowid) {
        RecordSet rs = new RecordSet();
        rs.execute(" select f.id from workflow_bill b left join workflow_billfield f on b.id=f.billid  left join modeinfo m on m.formid = f.billid\n" +
                "where b.id=(select formid from workflow_base where id='"+workflowid+"') and f.fieldname='"+fieldcode+"'");
        rs.next();
        String fieldid = Util.null2String(rs.getString("id"));
        if(fieldid !="" && fieldid !=null){
            RecordSet rs1 = new RecordSet();
            rs1.execute("select selectvalue,selectname from workflow_selectitem where fieldid='"+fieldid+"' and selectvalue='" + fieldvalue + "'");
            rs1.next();
            String selectname = Util.null2String(rs1.getString("selectname"));
            return selectname;
        }
        return fieldvalue;
    }
%>
